package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.domain.db.User;
import com.itheima.mapper.UserMapper;
import com.itheima.service.db.UserApi;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class UserApiImpl implements UserApi {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByPhone(String phone) {
        //创建查询对象
        QueryWrapper<User>queryWrapper =new QueryWrapper<>();
        queryWrapper.eq("phone",phone);
        return userMapper.selectOne(queryWrapper);
    }

    @Override
    public void updateUser(User currentUser) {
        QueryWrapper<User>queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",currentUser.getId());
        userMapper.update(currentUser,queryWrapper);
    }
}
